//index.js
Page({
  data: {
    searchValue:''
  },

// 搜索页面跳回
onLoad: function (options) {
    var that = this
    //这个if是否可以删除了？
    if (options && options.searchValue){
      this.setData({
        searchValue: options.searchValue
    });
    wx.request({
        url: 'https://data.docta.asia:8000/SearchCourse/',
        method: 'post',
        data:({
            searchValue: options.searchValue,
         }),
        header: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        success:function (res) {
            console.log(res) 
            const course_copy=res.data.search_course
            // 利用课程名称去得到课程信息
            const search_course=course_copy.map(item => ({course_name : item}))
            that.setData({search_course}) 
            console.log(that.data.search_course)
        }
    })

    }
    
},
  

  // 搜索入口  
  wxSearchTab: function () {
    wx.navigateTo({
      url: '../../pages/search/search',
    })
  }

})
